VERSION=0.2
NAME=pandoralastfm
MAIN=PandoraLastFm
DIST=$(NAME)-$(VERSION)
CLASSPATH=.:/System/Library/Java
WGET=download -v 

all: $(MAIN).class
run: $(MAIN).run
jar: $(NAME).jar
dist: $(DIST).tar.gz
lastfm: LastFm.run

.classpath: Makefile
	echo ".:/System/Library/Java:"`ls depends/*.jar | xargs | sed -e 's/ /:/g'` > $@

depends: Makefile
	mkdir -p $@
	cd $@ && $(WGET)  http://www.u-mass.de/software/last.fm-bindings-10.6.zip for f in *.zip do unzip $$f done && cd ..

%.class:%.java .classpath
	javac -g -classpath `cat .classpath` $<

%.run:%.class .classpath
	java -classpath `cat .classpath` $*

%.tar.gz:%.tar
	gzip -9 $<

$(DIST).tar: Makefile README *.java *.gif $(NAME) CHANGES
	tar cvf $@ $^

$(NAME).jar: manifest.mf $(MAIN).class *.gif *license.txt *.properties
	cp depends/*.jar .
	for f in *.jar; do \
		jar xvf $$f; \
	done
	jar cvfm $@ $< *.class *.gif *license.txt *.properties net

manifest.mf: Makefile $(MAIN).java
	echo "Main-class: $(MAIN)" > $@

allclean: distclean clean
	rm -f .classpath

distclean:
	rm -f $(DIST).tar $(DIST).tar.gz $(NAME).jar manifest.mf

clean:
	rm -f *~ *.class